package cn.iocoder.yudao.module.project.dal.mysql.order;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.project.controller.admin.internalcode.vo.InternalCodePageReqVO;
import cn.iocoder.yudao.module.project.controller.admin.internalcode.vo.InternalCodeRoleVO;
import cn.iocoder.yudao.module.project.controller.admin.internalcode.vo.InternalCodeWorkstationRespVO;
import cn.iocoder.yudao.module.project.dal.dataobject.order.OrderDO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.project.controller.admin.order.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 生产订单信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface OrderMapper extends BaseMapperX<OrderDO> {

    default PageResult<OrderDO> selectPage(OrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderDO>()
                .likeIfPresent(OrderDO::getId, reqVO.getId())
                .likeIfPresent(OrderDO::getCode, reqVO.getCode())
                // .betweenIfPresent(OrderDO::getOrderDate, reqVO.getOrderDate())
                .betweenIfPresent(OrderDO::getOrderDate, reqVO.getStartDate(), reqVO.getEndDate())
                .eqIfPresent(OrderDO::getTotalNum, reqVO.getTotalNum())
                .eqIfPresent(OrderDO::getArrivalPoint, reqVO.getArrivalPoint())
                .eqIfPresent(OrderDO::getDeliveryMode, reqVO.getDeliveryMode())
                .eqIfPresent(OrderDO::getManager, reqVO.getManager())
                .likeIfPresent(OrderDO::getBusinessName, reqVO.getBusinessName())
                .likeIfPresent(OrderDO::getOperator, reqVO.getOperator())
                .eqIfPresent(OrderDO::getRemark, reqVO.getRemark())
                .eqIfPresent(OrderDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(OrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderDO::getId));
    }




    List<OrderDO> selectSavedList(Map<String, Object> params);

    void insertList(List<OrderDO> insertList);

    void updateList(List<OrderDO> updateList);

    List<String> selectFlexListByOrderCode(Map<String, Object> params);

    List<OrderFlexNumVO> selectTypeNumByOrderCode(Map<String, Object> params);

    List<OrderRespVO> getOrderAndDispatchList(Page<OrderPageReqVO> pageParam, @Param("reqVO") OrderPageReqVO reqVO);

}